package com.itheima.zuoye.day04;

import java.util.Arrays;

/**
 * 作业:
 * 求次数:
 * 需求
 * 已知数组
 * int[] arr = {1, 90, 78, 65, 45, 67, 88,45, 99, 34,45};
 * 	求数组中 45 出现的次数.
 */
public class Test {
    public static void main(String[] args) {
        int[] arr = {1, 90, 78, 65, 45, 67, 88,45, 99, 34,45,99,99,99,90};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        int count = 0;
        for (int i = 1; i < arr.length; i++) {
            count++;

            if (arr[i] != arr[i-1]){
                System.out.println(arr[i-1]+"出现"+count+"次");
                count = 0;
            }
        }
        System.out.println(arr[arr.length-1]+"出现"+(count+1)+"次");
    }
}
